<?php
/**
* Copyright 2009 Waag Society <http://www.waag.org>
* This file is part of Annotrax.
*
* Annotrax is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* Annotrax is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Annotrax.
* If not, see http://www.gnu.org/licenses/gpl.html
*/
/**
 * Model class for Open Id Users
 *
 * @author Matthijs van Henten  <Matthijs@waag.org>
 * @license GNU GPL 2.0
 * @verson 0.1
 * @copyright Copyright (c) 2009, Waag Society
 */
class Default_Model_User extends At_Model{
    protected $_id;
    protected $_nickname;
    protected $_fullname;
    protected $_email;
    protected $_identifier;
	protected $_updated;
	protected $_inserted;

    /**
     * Sets the identifier for this user
     * immediately does a lookup so values may not be overwritten later!
     *
     * @param string $identifier A full identifier URL
     *
     * @return Default_Model_User $this
     */
    public function setIdentifier( $identifier ){
        $this->_identifier = $identifier;
		$this->find();

		return $this;
	}

	/**
	 * lookup this user. if id is set, lookup by id.
	 * else, lookup by identifier
	 */
	public function find(){
		if( null !== $this->_id ){
			$this->getMapper()->find( $this );
		}
		else if( null !== $this->_identifier ){
			$this->getMapper()->findByIdentifier( $this );
		}

	}


}
